from Numbers import rep_unit_len
from Primes import gen_primes
import itertools

def f(n):
    for p in itertools.takewhile(lambda x: x < n, gen_primes()):
        if p == 2 or p == 5:
            yield p
        else:
            rul = rep_unit_len(p)
            while rul % 2 == 0:
                rul /= 2
            while rul % 5 == 0:
                rul /= 5
            if rul > 1:
                yield p

print sum(f(100000))
